<?php
include "../inc-config.php";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Log In</title>
<style type="text/css">
<!--
body {
	background-color: #000000;
	background-image: url(../images/alliance-tile.jpg); background-repeat:repeat-x;
}
body,td,th {
	color: #CC9900;
	font-family: Arial, Helvetica, sans-serif;
	font-size: 13px;
}
a:link {
    color:#CC9900; 
	
	
}
a:visited {
    color:#CC9900;
	
}
a:hover {
    color:#ffffff;
}
a:active {
    color:#FF0000;
}

input { background:transparent; background-image:url(../images/transpblack.png); color:#FFFFFF; border: 1px solid #333333}
select { background-color:#000000; color:#FFFFFF; border: 1px solid #333333}
textarea { background-color:#000000; color:#FFFFFF; border: 1px solid #333333}

-->
</style>
</head>
<body>
<?php
if (isset($_POST['submit'])) // name of submit button
{
	$username = $_POST['user'];
	$username = strip_tags($username);
	$username = trim($username);
	if(!ctype_alnum($username))
	{
		echo "<br><br><br><br><center><font style='background-image:url(images/transpblack.png); border:solid 1px #000000; padding: 4px'>There were invalid characters in your name. Go back and try again.</font></center>";
	}
	else
	{
		$password = $_POST['password'];
		$password = trim($password);
		$password = md5($password);
		$query = "select * from b_users where username='$username' and password='$password' and validated='1'"; 
		$result = mysql_query($query, $forum) or die("Error #1: " . mysql_error());
		$result2 = mysql_fetch_array($result);
		if($result2)
		{         
			$_SESSION['user'] = $username;
			if($_POST['remember'])
			{
				$memberid = $result2['userID'];
				$passkey = $result2['password'];
				$cookie1 = "[0]";
				$cookie2 = "[1]";
				$cookie3 = "$cookiename$cookie1";
				$cookie4 = "$cookiename$cookie2";
				setcookie("$cookie3","$memberid",time()+7776000,'/',".chipmunk-scripts.com") ;
				setcookie("$cookie4","$passkey",time()+7776000,'/',".chipmunk-scripts.com") ;
			}
			echo "<br><br><br><br><center><font style='background-image:url(images/transpblack.png); border:solid 1px #000000; padding: 4px; color:#00CC00'>Logged in successfully. Redirecting to Forum Index ...</font></center>";
			echo "<META HTTP-EQUIV = 'Refresh' Content = '0; URL =index.php'></center>";
		}
	}
}
else
{ 
	echo "<br><br><br><br><center><font style='background-image:url(images/transpblack.png); border:solid 1px #000000; padding: 4px'>Wrong username or password or unactivated account, go back and try again.</font></center>";
}
?>
</body>
</html>